<template>
  <div ref="charts" class="charts"></div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  name: 'index',
  mounted () {
    //初始化charts实例
    echarts.init(this.$refs.charts).setOption({
      //x轴
      xAxis:{
        show:false,//隐藏x轴
        type: 'category'
      },
      //y轴
      yAxis:{
        show:false,
      },
      //系列
      series:[
        {
          type:'bar',//柱状图
          data:this.getRandom(),
          color:'green',
        }
      ],
      //布局调试
      grid:{
        left:0,
        top:0,
        right:0,
        bottom:0,
      },
      tooltip:{},
    })
  },
  methods: {
    getRandom(){
      let arr = []
      for(let i = 0;i < 9;i++){
        arr.push(Math.floor(Math.random()*(49)+2))
      }
      return arr
    }
  }
}
</script>

<style scoped>
.charts{
  width:100%;
  height:100%;
}
</style>
